#pragma once
// ============================================================================
// 文件：params_detector.hpp
// 说明：反光柱检测与地标维护所需的全部参数集合（两类共享）。
//      - 由“核心类 SLAM”通过 get_parameter(…) 填充。
//      - 由“订阅薄封装 ReflectorDetector”持有一份 paramsDetector 并传递给核心类。
// ============================================================================
#include <string>

struct ReflectorLandmark {
  Eigen::Vector2d center{0.0, 0.0};
  double radius{0.0};
  double strength{0.0};
  int    hits{0};
  rclcpp::Time last_seen{};
  std::string id{};
};


struct paramsDetector {
  // ===== Params / State =====
  std::string input_cloud_topic_{"/cx/cloud"};
  std::string marker_ns_{"reflectors"};
  std::string target_frame_{"map"};
  std::string laser_frame_{"laser"};

  double z_min_{-0.5}, z_max_{2.0};
  double range_min_{0.5}, range_max_{30.0};

  // 粗筛直线 I = a + b r 的两个锚点
  double coarse_r0_{1.0},  coarse_i0_{120.0};
  double coarse_r1_{25.0}, coarse_i1_{30.0};

    double bin_size_{1.0};
    int    min_points_per_bin_{60};
    double k_sigma_{2.0};
    double k_alpha_{1.2}; // 阈值=table_.k_alpha_(mu[bi] + table_.k_sigma_ * sd[bi])


  // 聚类/圆拟合
  double cluster_tolerance_{0.12};
  int    min_cluster_size_{6};
  int    max_cluster_size_{2000};

  double nominal_radius_{0.0375};
  double radius_gate_ratio_{0.5};
  double circle_inlier_eps_{0.02};

  bool   enable_near_recheck_{true};
  double near_range_{2.0};
  double near_low_ratio_{0.6};
  double near_i_trapezoid_{50};

  // 发布 Landmarks 的权重
  double lm_translation_weight_{1.0};
  double lm_rotation_weight_{1.0};

  // 地标维护
  double max_age_{30.0};
  double decay_threshold_{5.0};
  double decay_factor_{0.5};
  int    min_hits_{1};
  double max_distance_threshold_{0.5};

  // 运行期
  std::vector<ReflectorLandmark> landmarks_;

  // 全局强度-距离统计（跨帧累积）
  double global_rmin_{ std::numeric_limits<double>::infinity() };
  double global_rmax_{-std::numeric_limits<double>::infinity()};
  float  global_rmin_intensity_{0.f};
  float  global_rmax_intensity_{0.f};
};



